﻿using System;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

namespace Sizebox.CharacterEditor
{
	// Token: 0x0200025D RID: 605
	public class SaveDialog : MonoBehaviour
	{
		// Token: 0x06000D3D RID: 3389 RVA: 0x00069310 File Offset: 0x00067510
		private void Awake()
		{
			this.gameController = GameController.Instance;
			this.saveButton.onClick.AddListener(new UnityAction(this.OnSave));
			this.cancelButton.onClick.AddListener(new UnityAction(this.OnCancel));
		}

		// Token: 0x06000D3E RID: 3390 RVA: 0x00069360 File Offset: 0x00067560
		public void Open(string folderPath, UnityAction<string> saveCallback, string name = null)
		{
			base.gameObject.SetActive(true);
			this.folderPath = folderPath;
			this.callback = saveCallback;
			if (name != null)
			{
				this.nameInput.text = name;
			}
		}

		// Token: 0x06000D3F RID: 3391 RVA: 0x00069390 File Offset: 0x00067590
		private void OnSave()
		{
			if (this.callback == null || this.nameInput.text == string.Empty || this.nameInput.text == null)
			{
				return;
			}
			this.callback(this.nameInput.text);
			base.gameObject.SetActive(false);
		}

		// Token: 0x06000D40 RID: 3392 RVA: 0x00069260 File Offset: 0x00067460
		private void OnCancel()
		{
			base.gameObject.SetActive(false);
		}

		// Token: 0x06000D41 RID: 3393 RVA: 0x000693F5 File Offset: 0x000675F5
		private void OnEnable()
		{
			this.gameController.SetIsTyping(true);
		}

		// Token: 0x06000D42 RID: 3394 RVA: 0x00069403 File Offset: 0x00067603
		private void OnDisable()
		{
			this.callback = null;
			this.nameInput.text = string.Empty;
			this.gameController.SetIsTyping(false);
		}

		// Token: 0x0400123F RID: 4671
		private GameController gameController;

		// Token: 0x04001240 RID: 4672
		private string folderPath;

		// Token: 0x04001241 RID: 4673
		private UnityAction<string> callback;

		// Token: 0x04001242 RID: 4674
		[SerializeField]
		private Button saveButton;

		// Token: 0x04001243 RID: 4675
		[SerializeField]
		private Button cancelButton;

		// Token: 0x04001244 RID: 4676
		[SerializeField]
		private InputField nameInput;
	}
}
